package com.dong.web.util;

import javax.servlet.http.HttpServletRequest;

public final class WebUtil {

	private static String WEB_ROOT = null;

	public static String getBasePath(HttpServletRequest req) {
		String basePath = req.getScheme() + "://" + req.getServerName() + ":"
				+ req.getServerPort() + req.getContextPath() + "/";
		return basePath;
	}

	public static String getRoot(HttpServletRequest req) {
		if (WEB_ROOT == null) {
			WEB_ROOT = req.getContextPath() + "/";
		}
		return WEB_ROOT;
	}

}
